<template>
  <div id="cart">
    <nav-bar class="cart-navbar">
      <div slot="center">购物车({{ cartLength }})</div>
    </nav-bar>

    <scroll class="content" ref="scroll">
      <cart-list class="cart-list" :cart-list="cartListData"/>
    </scroll>
    <bottom-bar/>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'

import NavBar from '@/components/common/navbar/NavBar'
import CartList from '@/views/cart/childComps/CartList'
import Scroll from '@/components/common/scroll/Scroll'
import BottomBar from '@/views/cart/childComps/BottomBar'

export default {
  name: "Cart",
  components: {
    NavBar,
    CartList,
    Scroll,
    BottomBar,
  },
  computed: {
    // ...mapGetters(['cartLength']),
    cartLength() {
      return this.$store.getters.cartLength
    },
    cartListData() {
      return this.$store.getters.cartListData
    }
  },
  activated() {
    this.$refs.scroll.refresh()
  }
}
</script>

<style scoped>
#cart {
  height: 100vh;
}

.cart-navbar {
  background-color: var(--color-tint);
  color: #fff;
  font-size: 16px;
  position: relative;
  z-index: 10;
}

.content {
  position: absolute;
  top: 44px;
  bottom: 89px;
  width: 100%;
  overflow: hidden;
}
</style>
